import requests

# http代理
ip = "113.140.188.34"
port = 43561

proxies = {
    "http": "http://%s:%d" % (ip, port),
    "https": "http://%s:%d" % (ip, port)
}

# 请求头
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36"
}

# URL为通过百度搜索ip，响应内容中包括ip查询信息
url = "https://www.baidu.com/s?wd=ip"

r = requests.get(url=url, headers=headers, proxies=proxies, timeout=10)
# print(r.text)

with open("./百度查询ip-proxy.html", "w", encoding="utf-8") as f:
    f.write(r.text)
